package org.outlook.apps.goal.ui;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


public class LoginUI implements Runnable {

	private static final long serialVersionUID = 1L;
	private JFrame frame;
	private JDialog loginUI;
	private static JTextField userNameField;

	public LoginUI(JFrame frame) {
		this.frame = frame;
	}

	@Override
	public void run() {
		loginUI = new JDialog(frame, "Login", true);
//		final GridBagLayout gridBag = new GridBagLayout();
//		loginUI.setLayout(gridBag);
//		loginUI.setLayout(new FlowLayout());
//		GridBagConstraints gbc=new GridBagConstraints();
//		gbc.fill = GridBagConstraints.HORIZONTAL;
//		gbc.gridx = 0;
//		gbc.gridy = 0;
		JLabel usernameLabel = new JLabel("UserName:");
		usernameLabel.setBounds(20, 20, 50, 30);
//		gridBag.setConstraints(usernameLabel, gbc);
//		loginUI.add(usernameLabel, gbc);
		loginUI.add(usernameLabel);

//		gbc.gridx = 1;
//		gbc.gridwidth = 2;
		userNameField = new JTextField();
		userNameField.setBounds(80, 20, 80, 30);
//		userNameField.setPreferredSize(new Dimension(30,50));
//		userNameField.setSize(new Dimension(30,50));
//		gridBag.setConstraints(userNameField, gbc);
//		loginUI.add(userNameField, gbc);
		loginUI.add(userNameField);

//		gbc.gridx = 0;
//		gbc.gridy = 1;
//		gbc.gridwidth = 1;
		JLabel passwordLable = new JLabel("Password:");
		passwordLable.setBounds(20, 60, 50, 30);
//		gridBag.setConstraints(passwordLable, gbc);
//		loginUI.add(passwordLable, gbc);
		loginUI.add(passwordLable);

//		gbc.gridx = 1;
//		gbc.gridwidth = 2;
		JPasswordField passwordField = new JPasswordField(50);
		passwordField.setBounds(80, 60, 80, 30);
//		gridBag.setConstraints(passwordField, gbc);
//		loginUI.add(passwordField, gbc);
		loginUI.add(passwordField);

//		gbc.gridx = 2;
//		gbc.gridy = 2;
//		gbc.gridwidth = 1;
		JButton button = new JButton("Login");
		button.setBounds(120, 100, 30, 20);
//		gridBag.setConstraints(button, gbc);
//		loginUI.add(button, gbc);
		loginUI.add(button);

		loginUI.setPreferredSize(new Dimension(200,150));
		loginUI.setSize(new Dimension(200,120));
		setVisible(Boolean.TRUE);
	}

	public void setVisible(Boolean visible) {
		loginUI.setVisible(visible);
	}
	
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setPreferredSize(new Dimension(200,150));
		frame.setVisible(Boolean.TRUE);
		frame.pack();
		new Thread(new LoginUI(frame)).start();
	}

}
